package org.nicocube.airain.common.client;

import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;

public class ProgressCircle extends Composite {

	private static final String ONE_POINT = ".  ";
	private static final String TWO_POINT = ".. ";
	private static final String THREE_POINT = "...";	
	
	private HTML html;
	private Timer timer;
	private String c;

	public ProgressCircle() {
		c = ONE_POINT;
		html = new HTML(String.valueOf(c));
		initWidget(html);
	}
	
	@Override
	protected void onLoad() {
		timer = new Timer() {
			@Override
			public void run() {
				if (c.equals(ONE_POINT)) {
					c=TWO_POINT;
				} else if (c.equals(TWO_POINT)) {
					c=THREE_POINT;
				} else if (c.equals(THREE_POINT)) {
					c=ONE_POINT;
				}
				html.setHTML(c);
			}
		};
		timer.scheduleRepeating(300);
	}
	
	@Override
	protected void onUnload() {
		timer.cancel();
	}
	
}
